import time

import allure
from appium.webdriver.common.appiumby import AppiumBy

from base.wework_app import Wework


class EditMemberPage(Wework):
    """
    编辑成员页面
    """
    # 删除成员按钮
    _delete_member_btn = (AppiumBy.XPATH, "//*[@text='删除成员']")
    # 删除按钮
    _delete_btn = (AppiumBy.XPATH, "//*[@text='删除']")

    @allure.step("删除成员，返回通讯录页面")
    def delete_member(self):
        """
        删除成员，返回通讯录页面
        :return: 通讯录 page
        """
        from page.search_page import SearchPage
        # 滑动查找删除按钮，并点击删除
        self.swipe_find(self._delete_member_btn)
        # 等待1秒
        time.sleep(2)
        self.find_ele(self._delete_member_btn).click()
        # 确认删除
        self.find_ele(self._delete_btn).click()

        return SearchPage(self.driver)
